<?php
    require_once '../data/DataSet.php';
    require_once '../framework/RelatedItem.php';
    
    /**
     *	Component class
     *	Acts as an adapter, mapping a DataSet to an interface representation.
     *	@author	Simon Copsey <simon.copsey@gmail.com>
     *	@version 0.1
     *	@package interface
     */
    class Component {
	private $dataSet;
        private $title;
        private $subtitle;
        private $body;
        private $relatedItems =  array();
        
        /**
        * Create a new Component with reference to a given DataSet.
        *
        * @param DataSet $aDataSet the DataSet with which to populate component
        * @access public
        */        
	public function __construct($aDataSet) {
	    $this->dataSet = $aDataSet;
	}
	
	/**
        * Set Component title.
        *
        * @param Text $aTitle title
        * @access public
        */
	public function setTitle($aTitle) {
	    $this->title = $aTitle;
	}
        
        /**
        * Returns Component title.
        *
        * @return String title
        * @access public
        */
	public function getTitle() {
	    return $this->title;
	}

	/**
        * Set Component subtitle.
        *
        * @param Text $aSubtitle subtitle
        * @access public
        */
	public function setSubtitle($aSubtitle) {
	    $this->subtitle = $aSubtitle;
	}
        
                
        /**
        * Returns Component subtitle.
        *
        * @return String subtitle
        * @access public
        */
	public function getSubTitle() {
	    return $this->subtitle;
	}
        
	/**
        * Set Component body.
        *
        * @param Integer $aBody body
        * @access public
        */
	public function setBody($aBody) {
	    $this->body = $aBody;
	}
        
                
        /**
        * Returns Component body.
        *
        * @return String body
        * @access public
        */
	public function getBody() {
	    return $this->body;
	}
	
        /**
        * Add a related item to the current component.
        *
        * @param RelatedItem $aRelatedItem related item
        * @access public
        */
	public function addRelatedItem($aRelatedItem) {
            array_push($this->relatedItems, $aRelatedItem);
	}
        
        /**
        * Returns all related items.
        *
        * @return RelatedItem[] all related items 
        * @access public
        */
	public function getRelatedItems() {
	    return $this->relatedItems;
	}
    }
?>